package tblModelGerecht;

import java.util.ArrayList;

import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

import daoDataFactory.DaoFactory;
import domijn.Gerecht;
import pnlBeheer.PnlGDBeheer;

public class TMAGerecht implements TableModel {

	@SuppressWarnings("unused")
	private PnlGDBeheer pnlGDBeheer;
	private String []names = {"Categorie","Nummer","Naam","Prijs","Omschrijving"};
	private ArrayList<Gerecht> algerecht;
	private Gerecht g;

	public TMAGerecht(PnlGDBeheer pnlGDBeheer) {
		this.pnlGDBeheer = pnlGDBeheer;
		algerecht = DaoFactory.getwokapplicatie().getDaoIGerecht().loadGBA();      
		System.out.println(algerecht);
        }

	@Override
	public int getRowCount() {
		return algerecht.size();
	}

	@Override
	public int getColumnCount() {
		return names.length;
	}
	
	@Override
	public String getColumnName(int column) {
		return names[column];
	}

	@Override
	public Class<Gerecht> getColumnClass(int column) {
		return Gerecht.class;
	}

	@Override
	public boolean isCellEditable(int arg0, int arg1) {
		return false;
	}
	
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		g = algerecht.get(rowIndex);
		 switch (columnIndex){
        case 0:
        	return g.getCat();
        case 1:
            return g.getGrNewNumber();
        case 2:
        	return g.getGrName();
        case 3:
       	 	return g.getGrPrice();
        case 4: 
        	return g.getGrDiscr();
           }
       return g;
       }
	public void refresh (Gerecht objecten){
		 refresh(null);
	}
	
	@Override
	public void setValueAt(Object arg0, int arg1, int arg2) {
	}
	
	@Override
	public void addTableModelListener(TableModelListener arg0) {
	}
	
	@Override
	public void removeTableModelListener(TableModelListener arg0) {
	}

    public void addGerecht(final Gerecht gerecht) {
        algerecht.add(gerecht);
    }
}